package cn.lili.modules.urbansubstation.entity.dto;

import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * 城市分站激活码列表搜索参数
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class VipCodeSearchParams implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "激活码")
    private String activeCode;

    @ApiModelProperty(value = "状态：0未使用、1已使用、2冻结")
    private Integer status;

    @ApiModelProperty(value = "状态：0未使用、1已使用、2冻结--冗余--前段穿的这个字段")
    private Integer activeStatus;

    @ApiModelProperty(value = "使用人")
    private String userName;

    @ApiModelProperty(value = "城市站点ID")
    private String urbanId;

    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        if (CharSequenceUtil.isNotEmpty(userName)) {
            queryWrapper.eq("user_name", userName);
        }
        if (CharSequenceUtil.isNotEmpty(activeCode)) {
            queryWrapper.eq("active_code", activeCode);
        }
        if (status != null) {
            queryWrapper.eq("status", status);
        }
        if (activeStatus != null) {
            queryWrapper.eq("active_status", activeStatus);
        }
        if (CharSequenceUtil.isNotEmpty(urbanId)) {
            queryWrapper.eq("supplier_id", urbanId);
        }
        return queryWrapper;
    }
}
